package com.demo.codeGenerator;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class StreamDemo2 {  
	  
    public static void main(String[] args) {  
        List<Student> lists = new ArrayList<Student>();  
        lists.add(new Student(1,"张三","男"));  
        lists.add(new Student(2,"李四","男"));  
        lists.add(new Student(3,"赵六","女"));  
          
        Stream<Student> stream = lists.stream();  
          
        Stream<Student> boyStream=stream.filter((Student s)-> s.getSexy().equals("男"));  
        System.out.println("男的人数:"+boyStream.count());  
          
        IntStream  is = lists.stream().mapToInt((Student s)->s.getId());  
        System.out.println("ID编号之和为:"+is.sum());  
    }  
  
}

class Student{  
    Integer id;   
    String name;  
    String sexy;      
      
    public Student(Integer id, String name, String sexy) {  
        super();  
        this.id = id;  
        this.name = name;  
        this.sexy = sexy;  
    }  
    public Integer getId() {  
        return id;  
    }  
    public void setId(Integer id) {  
        this.id = id;  
    }  
    public String getName() {  
        return name;  
    }  
    public void setName(String name) {  
        this.name = name;  
    }  
    public String getSexy() {  
        return sexy;  
    }  
    public void setSexy(String sexy) {  
        this.sexy = sexy;  
    }  
}  